BambooBasic Network Examples
============================

This folder contains examples demonstrating TCP and UDP networking.

TCP Examples (Connection-based)
--------------------------------

TCPServer.bam / TCPClient.bam
  Demonstrates TCP client/server communication over localhost (127.0.0.1)

  How to run:
  1. Open TWO command prompt windows
  2. In window 1: Run TCPServer.exe
  3. In window 2: Run TCPClient.exe (while server is waiting)

  The client will connect to the server, exchange messages, and disconnect.


UDP Examples (Connectionless)
------------------------------

UDPReceiver.bam / UDPSender.bam
  Demonstrates UDP packet-based communication

  How to run:
  1. Open TWO command prompt windows
  2. In window 1: Run UDPReceiver.exe
  3. In window 2: Run UDPSender.exe (while receiver is listening)

  The sender will transmit packets to the receiver without establishing a connection.


Interactive Chat
----------------

You will have to build the InteractiveChat.bam file, and run the same executable
in TWO command prompt windows, select the "Server" version in the first console window,
then select "Client" version in the second. When connected, the application will have and
little chat with each other.

Key Functions
-------------

TCP:
  BBR_CreateTCPServer(port) - Create a TCP server
  BBR_AcceptTCPStream(server) - Accept incoming connection
  BBR_OpenTCPStream(ip, port) - Connect to a TCP server
  BBR_WriteTCPString(handle, message) - Send string data
  BBR_ReadTCPString(handle, maxSize) - Read string data
  BBR_CloseTCPStream(handle) - Close connection
  BBR_CountAvailableBytes(handle) - Check bytes available to read

UDP:
  BBR_CreateUDPStream(port) - Create UDP socket
  BBR_SendUDPString(handle, ip, port, message) - Send packet
  BBR_RecvUDPString(handle, maxSize) - Receive packet
  BBR_UDPMsgIP(handle) - Get sender IP from last received packet
  BBR_UDPMsgPort(handle) - Get sender port from last received packet
  BBR_CloseUDPStream(handle) - Close UDP socket


Notes
-----
- All examples use localhost (127.0.0.1) for safe local testing
- TCP is connection-oriented and guarantees delivery
- UDP is connectionless and does not guarantee delivery
- Sockets are non-blocking in these examples
